/*
 * Copyright (C) 2012-2013 Matthias Zeimer and the miniframes project group.
 * All rights reserved. 
 * 
 * Licensed under the Eclipse Public License, Version 1.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.opensource.org/licenses/EPL-1.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package de.miniframes.minivalues;

import java.io.Serializable;
import java.util.Locale;

/**
 * <p>
 * A domain value is a {@linkplain Value value} which is inspired by the domains
 * experts. These values are domain specific and have a concrete equivalent in
 * the softwares domain. Domain experts will understand the meaning of a
 * concrete sub-type.
 * </p>
 * 
 * <p>
 * See examples in <a href="./package-summary.html">packages documentation</a>.
 * </p>
 * 
 * @author Matthias Zeimer
 * @version 0.3
 * @since 0.1, 10.01.2013
 * @param <T>
 *            The concrete domain value, the implementation class
 *            (auto-reflexive declaration). If the class of the subclass is
 *            {@code X} the inheritance would be declared as
 *            {@code X extends DomainValue<X>}. Abstract subclasses must pass
 *            the type of a concrete subclass using their own type argument.
 */
public abstract class DomainValue<T extends DomainValue<T>> extends Value<T> {

    /**
     * <p>
     * The serial version UID of this class.
     * </p>
     * 
     * @see Serializable
     */
    private static final long serialVersionUID = 3736889683442152901L;

    /**
     * <p>
     * Creates an instance for de-serialisation support. The created instance is
     * invalid and need is to be filled by the JVM with approximate data.
     * </p>
     * 
     * <p>
     * To be used by the JVM only. This constructor should never be called
     * immediately.
     * </p>
     */
    protected DomainValue() {
        super();
    }

    protected DomainValue(final String toStringFormat,
            final Object... properties) {
        super(toStringFormat, properties);
    }

    public final String toLocalisedString(final Locale locale) {
        final StringBuilder result = new StringBuilder();
        this.produceToLocalisedStringResult(locale, result);
        return result.toString();
    }

    protected void produceToLocalisedStringResult(final Locale locale,
            final StringBuilder result) {
        result.append(this.toString());
    }
}
